In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from IPython.display import Image
In [2]:
# open MERIS L1 data
from nansat import Nansat
n1 = Nansat('/files/normap/MER_FRS_1PNUPA20110908_092035_000005513106_00223_49806_1826.N1')
print n1
In [3]:
# open ASAR L1 data
n2 = Nansat('/files/normap/ASA_WSM_1PNPDK20060404_091239_000000852046_00308_21404_2157.N1')
print n2
In [4]:
# open local NORMAP SST dataset
n3 = Nansat('/files/normap/20130701000000-METNO-L4_GHRSST-SSTfnd-METNO_OI-ARC-v02.0-fv02.0.nc')
print n3
In [5]:
# open remote NORMAP dataset
url = 'http://thredds.nersc.no/thredds/dodsC/normap/arctic12km_seaice/arctic12km_seaice_19870801_19870831.nc'
n4 = Nansat(url)
print n4
In [6]:
n1.write_map('footprint.png', pltshow=True)
In [7]:
f = n1.write_figure('gray.jpg', 5, clim='hist', ratio=0.8, logarithm=True, cmapName='gray')
Image('gray.jpg')
Out[7]:
In [8]:
f = n1.write_figure('rgb.jpg', bands=['L_709', 'L_560', 'L_413'], clim='hist', ratio=0.8, logarithm=True)
Image('rgb.jpg')
Out[8]:
In [9]:
n1.crop(2000, 5000, 2000, 2000)
# and make an figure of a cropped image
f = n1.write_figure('rgb_cropped.jpg', bands=['L_709', 'L_560', 'L_413'], clim='hist', ratio=0.8, logarithm=True)
Image('rgb_cropped.jpg')
Out[9]:
In [3]:
from nansat import Domain
d1 = Domain('+proj=longlat', '-te 21 68 41 74 -tr 0.1 0.1')
d1.write_map('longlat.png', pltshow=True)
In [11]:
n1.reproject(d1, 2)
# and make a figure of reprojected dataset
f = n1.write_figure('rgb_longlat.jpg', bands=['L_709', 'L_560', 'L_413'], clim='hist', ratio=0.8, logarithm=True)
Image('rgb_longlat.jpg')
Out[11]:
In [12]:
d2 = Domain('+proj=stere +lon_0=32 +lat_0=71', '-te -200000 -200000 200000 200000 -tr 300 300')
d2.write_map('stere.png', pltshow=True)
In [13]:
n1.undo(100)
n1.reproject(d2, 2)
# and make a figure of reprojected dataset
f = n1.write_figure('rgb_stere.jpg',
bands=['L_709', 'L_560', 'L_413'],
clim='hist',
ratio=0.8,
logarithm=True)
Image('rgb_stere.jpg')
Out[13]:
In [14]:
n1.export('meris_L_413.nc', ['L_413'])
!ncdump -h meris_L_413.nc
In [23]:
n1 = Nansat('/files/normap/20130701000000-METNO-L4_GHRSST-SSTfnd-METNO_OI-ARC-v02.0-fv02.0.nc')
n2 = Nansat('/files/normap/arctic8km_adt_20130701_20130930.nc')
n3 = Nansat('/files/normap/ice_conc_nh_polstere-100_multi_201307011200.nc')
d = Domain(4326, '-te -12 60 20 81 -tr 0.05 0.05')
n1.reproject(d)
n2.reproject(d)
n3.reproject(d)
sst = n1['analysed_sst']
u = n2['u']
v = n2['v']
ice_conc = n3['ice_conc']
plt.figure(figsize=(15,15))
plt.subplot(131)
plt.imshow(sst, vmin=270, vmax=286)
plt.subplot(132)
plt.imshow(ice_conc, vmin=0, vmax=100)
plt.subplot(133)
plt.imshow(u ** 2 + v ** 2, vmin=0, vmax=.01)
Out[23]:
In [16]:
# get landmask
watermask = n1.watermask('/files/MOD44W/')[1]
In [24]:
# mask land
sst[watermask == 2] = np.nan
u[watermask == 2] = np.nan
v[watermask == 2] = np.nan
ice_conc[watermask == 2] = np.nan
# mask invalid U and V
u[u<-10] = np.nan
v[v<-10] = np.nan
# mask zero ice concentration
ice_conc[ice_conc <= 0] = np.nan
# mask under-ice currents
u[ice_conc > 0] = np.nan
v[ice_conc > 0] = np.nan
# mask invalid SST
sst[sst < 0] = np.nan
plt.figure(figsize=(15,15))
plt.subplot(131)
plt.imshow(sst, vmin=270, vmax=286)
plt.subplot(132)
plt.imshow(ice_conc, vmin=0, vmax=100)
plt.subplot(133)
plt.imshow(np.hypot(u, v), vmin=0, vmax=.1)
Out[24]:
In [26]:
from nansat import Nansatmap
nmap = Nansatmap(n3, resolution='l')
nmap.pcolormesh(sst-273.15, vmin=-5, vmax=13)
nmap.pcolormesh(ice_conc, cmap='bone')
nmap.quiver(u, v, step=7, scale=4, width=0.001)
nmap.draw_continents()
nmap.drawmeridians(np.arange(-12, 20, 5), labels=[False,False,True,False])
nmap.drawparallels(np.arange(60, 81, 3), labels=[True, False, False, False])
# set size of the figure (inches)
nmap.fig.set_figheight(20)
nmap.fig.set_figwidth(15)
# save figure to a PNG file
nmap.save('normap_map.png')
In [20]:
# open files
n1 = Nansat('/files/normap/20130701000000-METNO-L4_GHRSST-SSTfnd-METNO_OI-ARC-v02.0-fv02.0.nc')
n2 = Nansat('/files/normap/arctic8km_adt_20130701_20130930.nc')
# define start and end of transects
points = [[(4, 62), (-8, 73)]]
# extract transects
values1, lonlat1, pixlin1 = n1.get_transect(points)
values2, lonlat2, pixlin2 = n2.get_transect(points)
# plot
sst = values1['1:analysed_sst']['shape0']
lat1 = lonlat1['shape0']['latitude']
v = values2['1:v']['shape0']
lat2 = lonlat2['shape0']['latitude']
fig, ax1 = plt.subplots(figsize=(10,10))
ax1.plot(lat1, sst, '.-k', label='SST')
ax1.set_ylabel('SST, K')
ax1.legend(loc=1)
ax2 = ax1.twinx()
ax2.plot(lat2, v, 'o-', label='V')
ax2.set_ylim([-.1, .1])
ax2.set_ylabel('V, m/s')
ax2.legend(loc=3)
plt.show()
In [21]:
import glob
from dateutil.parser import parse
# define start and end of transects
points = [(4, 62)]
# list files in time series
adtFiles = sorted(glob.glob('/files/normap/arctic8km_adt*'))
speeds = []
dates = []
# loop through files
for adtFile in adtFiles:
# open file with nansat
n = Nansat(adtFile)
# fetch data from transect
values, lonlat, pixlin = n.get_transect(points, bandList=[1,2])
v = values['1:v']['shape0']
u = values['2:u']['shape0']
# add data for hovmoller plot
speeds.append(np.hypot(u, v)[0])
# get time
dates.append(parse(n.get_metadata('time_coverage_start')))
# create Hovmoller plot
fig = plt.figure(figsize=(10,10))
plt.plot(dates, speeds, 'o-')
plt.xlabel('Date')
plt.ylabel('Geostrophic current speed at 4oE 62oN')
Out[21]:
In [ ]:
nn = Nansat('http://www.ifremer.fr/opendap/cerdap1/globcurrent/global_010_deg/total_hs/2012/183/20120701000000-GLOBCURRENT-L4-CUR-ALT-total_hs-v01.0-fv01.0.nc')
In [28]:
print nn
In [30]:
nn.reproject(d)
u = nn['eastward_total_current_velocity_hs000']
v = nn['northward_total_current_velocity_hs000']
lons, lats = nn.get_geolocation_grids()
In [2]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from IPython.display import Image
from nansat import Nansat, Domain, Nansatmap
n1 = Nansat('/files/normap/20130701000000-METNO-L4_GHRSST-SSTfnd-METNO_OI-ARC-v02.0-fv02.0.nc')
n3 = Nansat('/files/normap/ice_conc_nh_polstere-100_multi_201307011200.nc')
d = Domain(4326, '-te -12 60 20 81 -tr 0.05 0.05')
n1.reproject(d)
n3.reproject(d)
sst = n1['analysed_sst']
ice_conc = n3['ice_conc']
# mask land
watermask = n1.watermask('/files/MOD44W/')[1]
sst[watermask == 2] = np.nan
u[watermask == 2] = np.nan
v[watermask == 2] = np.nan
ice_conc[watermask == 2] = np.nan
# mask invalid U and V
u[u<-10] = np.nan
v[v<-10] = np.nan
# mask zero ice concentration
ice_conc[ice_conc <= 0] = np.nan
# mask under-ice currents
u[ice_conc > 0] = np.nan
v[ice_conc > 0] = np.nan
# mask invalid SST
sst[sst < 0] = np.nan
nmap = Nansatmap(n3, resolution='l')
nmap.pcolormesh(sst-273.15, vmin=-5, vmax=13)
nmap.pcolormesh(ice_conc, cmap='bone')
nmap.streamplot(lons, lats, u, v, density=5, linewidth=np.hypot(u,v)*10, color='k')
nmap.draw_continents()
nmap.drawmeridians(np.arange(-12, 20, 5), labels=[False,False,True,False])
nmap.drawparallels(np.arange(60, 81, 3), labels=[True, False, False, False])
# set size of the figure (inches)
nmap.fig.set_figheight(20)
nmap.fig.set_figwidth(15)
# save figure to a PNG file
nmap.save('normap_globcurrent_map.png')
In [ ]: